﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class EditProfile : System.Web.UI.Page
{
    eStoreDataContext db = new eStoreDataContext();
    protected void Page_PreRender(object sender, EventArgs e)
    {
        var user = Session["user"] as Customer;

         txtUsername.Text=user.CusId;
         txtFullName.Text=user.Fullname;
         txtEmail.Text=user.Email;
         txtBirthday.Text=(Convert.ToDateTime(user.Birthday)).ToString();
         rdo_gioitinh.SelectedValue=user.Sex.ToString();
         txtPhone.Text=user.Phone;
         txtAddress.Text = user.Address;
    }
    protected void btnUpdate_Click(object sender, EventArgs e)
    {
        var user = db.Customers.Single(c => c.CusId == txtUsername.Text);
        user.Fullname = txtFullName.Text;
        user.Email = txtEmail.Text;
        user.Address = txtAddress.Text;
        user.Birthday =Convert.ToDateTime(txtBirthday.Text);
        user.Sex = Convert.ToBoolean(rdo_gioitinh.SelectedValue);
        user.Phone = txtPhone.Text;
        db.SubmitChanges();
        Session["user"] = user;
    }
}